//
// Created by tang on 2022/1/10.
//

#ifndef DIARYTOOL_APP_HPP
#define DIARYTOOL_APP_HPP

#include <string>

#ifdef CreateWindow // F**k WIN32
#undef CreateWindow
#endif

#include "app/app_base.hpp"
#include "gui/form.hpp"
#include "sql/sql_driver.hpp"

class MainFromBase;

class Application final : public ApplicationBase {
    MainFromBase* m_main_form_;
    ISqlDriver* m_sql_driver_;
    Listener      m_event_listener_;
    std::atomic_bool m_running_;
    static std::vector<const DriverFactory*> m_sql_drivers_;
public:
    Application();

    ~Application() override;

    static void RegisterSqlDriver(const DriverFactory* factory);

    void Run(MainFromBase* form);

    static int SqlDriverCount();

    static const char* SqlDriverName(int index);

    void Exit() override;

    MainFromBase* RootForm() const;

    ISqlDriver* Sql() const override;

    void ShowDialog(const std::string& name) const override;

    void SetupSqlDriver() override;

    void ShowStatusMessage(const std::string& msg, float timeout) const override;
};

#endif //DIARYTOOL_APP_HPP
